TextInput
| Kind of class: | class |
|---|---|
| Inherits from: | UIComponent < MovieClip |
| Known subclasses: | |
| Classpath: | gfx.controls.TextInput |
| File last modified: | Tuesday, 29 June 2010, 09:03:27 |
TextInput is an editable text field component used to capture textual user input. Similar to the Label, this component is merely a wrapper for a standard textField, and therefore supports the same capabilities of the textField such as password mode, maximum number of characters and HTML text. Only a handful of these properties are exposed by the component itself, while the rest can be modified by directly accessing the TextInput’s textField instance.
The TextInput component should be used for input, since noneditable text can be displayed using the Label. Similar to the Label, developers may substitute standard textFields for TextInput components based on their requirements. However, when developing sophisticated UIs, especially for PC applications, the TextInput component provides valuable extended capabilities over the standard textField.
For starters, TextInput supports the focused and disabled state, which are not easily achieved with the standard textField. Due to the separated focus state, TextInput can support custom focus indicators, which are not included with the standard textField. Complex AS2 code is required to change the visual style of a standard textField, while the TextInput visual style can be configured easily on the timeline. The TextInput inspectable properties provide an easy workflow for designers and programmers who are not familiar with Flash Studio. Developers can also easily listen for events fired by the TextInput to create custom behaviors.
The TextInput also supports the standard selection and cut, copy, and paste functionality provided by the textField, including multi paragraph HTML formatted text. By default, the keyboard commands are select (Shift+Arrows), cut (Shift+Delete), copy (Ctrl+Insert), and paste (Shift+Insert).
Inspectable Properties
The inspectable properties of the TextInput component are:
The CLIK TextInput component supports three states based on its focused and disabled properties.
All event callbacks receive a single Object parameter that contains relevant information about the event. The following properties are common to all events.
The TextInput component should be used for input, since noneditable text can be displayed using the Label. Similar to the Label, developers may substitute standard textFields for TextInput components based on their requirements. However, when developing sophisticated UIs, especially for PC applications, the TextInput component provides valuable extended capabilities over the standard textField.
For starters, TextInput supports the focused and disabled state, which are not easily achieved with the standard textField. Due to the separated focus state, TextInput can support custom focus indicators, which are not included with the standard textField. Complex AS2 code is required to change the visual style of a standard textField, while the TextInput visual style can be configured easily on the timeline. The TextInput inspectable properties provide an easy workflow for designers and programmers who are not familiar with Flash Studio. Developers can also easily listen for events fired by the TextInput to create custom behaviors.
The TextInput also supports the standard selection and cut, copy, and paste functionality provided by the textField, including multi paragraph HTML formatted text. By default, the keyboard commands are select (Shift+Arrows), cut (Shift+Delete), copy (Ctrl+Insert), and paste (Shift+Insert).
Inspectable Properties
The inspectable properties of the TextInput component are:
- text: Sets the text of the textField.
- visible: Hides the component if set to false.
- disabled: Disables the component if set to true.
- editable: Makes the TextInput non-editable if set to false.
- maxChars: A number greater than zero limits the number of characters that can be entered in the textField.
- password: If true, sets the textField to display '*' characters instead of the real characters. The value of the textField will be the real characters entered by the user – returned by the text property.
- defaultText: Text to display when the textField is empty. This text is formatted by the defaultTextFormat object, which is by default set to light gray and italics.
- actAsButton: If true, then the TextInput will behave similar to a Button when not focused and support rollOver and rollOut states. Once focused via mouse press or tab, the TextInput reverts to its normal mode until focus is lost.
- enableInitCallback: If set to true, _global.CLIK_loadCallback() will be fired when a component is loaded and _global.CLIK_unloadCallback will be called when the component is unloaded. These methods receive the instance name, target path, and a reference the component as parameters. _global.CLIK_loadCallback and _global.CLIK_unloadCallback should be overriden from the game engine using GFx FunctionObjects.
- soundMap: Mapping between events and sound process. When an event is fired, the associated sound process will be fired via _global.gfxProcessSound, which should be overriden from the game engine using GFx FunctionObjects.
The CLIK TextInput component supports three states based on its focused and disabled properties.
- default or enabled state.
- focused state, typically a represented by a highlighted border around the textField.
- disabled state.
All event callbacks receive a single Object parameter that contains relevant information about the event. The following properties are common to all events.
- type: The event type.
- target: The target that generated the event.
- show: The component’s visible property has been set to true at runtime.
- hide: The component’s visible property has been set to false at runtime.
- focusIn: The component has received focus.
- focusOut: The component has lost focus.
- textChange: The text field contents have changed.
- rollOver: The mouse cursor has rolled over the component when not focused. Only fired when the actAsButton property is set.
- controllerIdx: The index of the mouse cursor used to generate the event (applicable only for multi-mouse-cursor environments). Number type. Values 0 to 3.
- rollOut: The mouse cursor has rolled out of the component when not focused. Only fired when the actAsButton property is set.
- controllerIdx: The index of the mouse cursor used to generate the event (applicable only for multi-mouse-cursor environments). Number type. Values 0 to 3.
Component metadata:
| InspectableList | "actAsButton" "defaultText" "disabled" "editable" "enableInitCallback" "maxChars" "password" "soundMap" "textID" "visible" |
|---|
Summary
Constructor
Instance properties
- defaultText
- The default text to be shown when no text has been assigned or entered into this component.
- defaultTextFormat
- The text format used to display the default text.
- soundMap
- Mapping between events and sound process
- textField
- A reference the on-stage TextField instance.
- textID
- Set the text parameter of the component using the Locale class to look up a localized version of the text from the Game Engine.
- text
- Get and set the text of the component using ActionScript.
- htmlText
- Get and set the html text of the component.
- editable
- Determines if text can be entered into the TextArea, or if it is display-only.
- password
- The "password" mode of the text field.
- maxChars
- The maximum number of characters that the field can contain.
- disabled
- Disable this component.
- length
- The length of the text in the textField.
Instance properties inherited from UIComponent
__height __width _disabled _displayFocus _focused addEventListener cleanUpEvents disabled dispatchEvent displayFocus enableInitCallback focused focusHandlerReference focusTarget hasEventListener height initialized invalidationIntervalID removeAllEventListeners removeEventListener sizeIsInvalid soundMap visible width
Class methods
Class methods inherited from UIComponent
Instance methods
- appendText
- Append a new string to the existing text.
- appendHtml
- Append a new html string to the existing text.
- handleInput
- Handle input from the game, via controllers or keyboard.Instance methods inherited from UIComponent
Constructor
TextInput
function TextInput (
)
The constructor is called when a TextInput or a sub-class of TextInput is instantiated on stage or by using
attachMovie() in ActionScript. This component can not be instantiated using new syntax. When creating new components that extend TextInput, ensure that a super() call is made first in the constructor. Instance properties
defaultText
defaultText:String = ""
(read,write)
The default text to be shown when no text has been assigned or entered into this component.
defaultTextFormat
defaultTextFormat:TextFormat
(read,write)
The text format used to display the default text. By default it is set to color:0xAAAAAA and italic:true.
disabled
disabled:Boolean
(read,write)
Disable this component. Focus (along with keyboard events) and mouse events will be suppressed if disabled.
editable
editable:Boolean
(read,write)
Determines if text can be entered into the TextArea, or if it is display-only. Text in a non-editable TextInput components can not be selected.
htmlText
htmlText:String
(read,write)
Get and set the html text of the component. Html text can be formatted using the tags supported by ActionScript.
length
length:Number
(read)
The length of the text in the textField.
maxChars
maxChars:Number
(read,write)
The maximum number of characters that the field can contain.
password
password:Boolean
(read,write)
The "password" mode of the text field. When
true, the component will show asterisks instead of the typed letters. soundMap
soundMap:Object = { theme:"default", focusIn:"focusIn", focusOut:"focusOut", textChange:"textChange" }
(read,write)
Mapping between events and sound process
text
text:String
(read,write)
Get and set the text of the component using ActionScript. The
text property can only set plain text. For formatted text, use the htmlText property, or set html=true, and use TextFormat instead. textField
textField:TextField
(read,write)
A reference the on-stage TextField instance. Note that when state changes are made, the textField instance may change, so changes made to it externally may be lost.
textID
textID:String
(read,write)
Set the
text parameter of the component using the Locale class to look up a localized version of the text from the Game Engine. This property can be set with ActionScript, and is used when the text is set using the Component Inspector. Instance methods
appendHtml
function appendHtml (
text:String) : Void
Append a new html string to the existing text. The textField will be set to html rendering when this method is invoked.
appendText
function appendText (
text:String) : Void
Append a new string to the existing text. The textField will be set to non-html rendering when this method is invoked.
handleInput
Handle input from the game, via controllers or keyboard. The default handleInput will handle standalone and composite components.
Parameters:
details :
An
InputDetails object containing details from the interaction.pathToFocus:
A list of children in the focus path that are below this component. Components are responsible for calling
handleInput() on the next component in the pathToFocus unless they choose to intercept the call.Overrides: